<template>
  <div>
    <header class="mui-bar mui-bar-nav title">
      <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left title-a" @tap="back()"></a>
      <h1 class="mui-title title-a">主页</h1>
    </header>
    <div class="mui-content" style="padding-top: 44px;" >
      <ul class="mainmenu">
        <li v-for="menu in data.menuList"><a :href="splitUrl(menu)">
        	<b>
        		<img :src="setUrl(menu.type)" />
        		<span class="mui-badge propelling-info fixedApply" v-if="menu.pageCount > 0">{{menu.pageCount}}</span></b><span class="menu-description">{{menu.name}}</span></a></li>
      </ul>
    </div>
  </div>
</template>
<script>
import store from '../login-store';
var modules = {
  1: 'fixed',
  2: 'fixed',
  3: 'print',
  4: 'vehicleApply',
  5: 'vehicleRepair',
  6: 'lowval',
  7: 'opty'
};
export default {
  data: function () {
    return {
      data: store.state,
      modules: modules
    };
  },
  created: function () {
    store.init();
  },
  watched: function () {
    store.init();
  },
  methods: {
    setUrl: function (val) {
      return require('../../public/images/' + modules[val] + '.png');
    },
    splitUrl: function (menu) {
      var type = menu.type;
      var url = menu.url;
      return url + '/index.html?type=' + type;
    }
  }
};
</script>
